/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.seari.bean;

import java.util.Arrays;
import java.util.List;

/**
 *
 * @author Rainbow
 */
public class User
{
	// 用户id
	Long uid;
	// 用户名
    String userName;
    //用户密码
    String password;
    // 车站名
    String stationName;
    // 角色ID组
    int [] urids;
    String token;
    int status;
    //角色对象集合
    List<Role> userRoles;
	public User(Long uid, String userName, String password, String stationName,
			int[] urids, String token, int status, List<Role> userRoles) {
		super();
		this.uid = uid;
		this.userName = userName;
		this.password = password;
		this.stationName = stationName;
		this.urids = urids;
		this.token = token;
		this.status = status;
		this.userRoles = userRoles;
	}
	public User() {
		super();
		// TODO Auto-generated constructor stub
	}
	public Long getUid() {
		return uid;
	}
	public void setUid(Long uid) {
		this.uid = uid;
	}
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getStationName() {
		return stationName;
	}
	public void setStationName(String stationName) {
		this.stationName = stationName;
	}
	public int[] getUrids() {
		return urids;
	}
	public void setUrids(int[] urids) {
		this.urids = urids;
	}
	public String getToken() {
		return token;
	}
	public void setToken(String token) {
		this.token = token;
	}
	public int getStatus() {
		return status;
	}
	public void setStatus(int status) {
		this.status = status;
	}
	public List<Role> getUserRoles() {
		return userRoles;
	}
	public void setUserRoles(List<Role> userRoles) {
		this.userRoles = userRoles;
	}

	public String getRolesNameString(){
		StringBuilder names = new StringBuilder("/");
		if(this.userRoles != null && this.userRoles.size() > 0){
			names.deleteCharAt(names.indexOf("/"));
			for (Role userRole : this.userRoles) {
				names.append(userRole.getRoleName()).append(",");
			}
			names.deleteCharAt(names.lastIndexOf(","));
		}
		return names.toString();
	}
	@Override
	public String toString() {
		return "User [uid=" + uid + ", userName=" + userName + ", password="
				+ password + ", stationName=" + stationName + ", urids="
				+ Arrays.toString(urids) + ", token=" + token + ", status="
				+ status + ", userRoles=" + userRoles + "]";
	}

	
    
	
	
    
    
}
